package com.example.jh352160.surfingtv.mypage.customView.adapter;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import java.util.List;

/**
 * Created by jh352160 on 2016/7/27
 */

public class FavoritesPagerAdapter extends PagerAdapter {

    private List<View> viewList;

    public FavoritesPagerAdapter(List<View> imageList) {
        this.viewList = imageList;
    }

    @Override
    public int getCount() {
        return viewList.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        container.addView(viewList.get(position));
        return viewList.get(position);
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView(viewList.get(position));
    }

    @Override
    public CharSequence getPageTitle(int position) {
        String[] title = {"专题", "商品"};
        return title[position];
    }
}
